<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<include file="public:meta"/>
<link href="../public/css/company/common.css" rel="stylesheet" type="text/css"/>
<link href="../public/css/company/company_user.css" rel="stylesheet" type="text/css"/>
<link href="../public/css/company/company_ajax_dialog.css" rel="stylesheet" type="text/css"/>
<script src="../public/js/company/jquery.common.js" type="text/javascript" language="javascript"></script>
</head>
<body>
<include file="index_header"/>
<div class="user_main">
    <div class="mleft">
        <include file="left_user"/>
    </div>
    <div class="mright">
        <div class="user_pagetitle">
            <div class="pat_l">企业认证</div>
            <div class="clear"></div>
        </div>
        <div class="user_tip">
            <div class="tiptit">小提示</div>
            <div class="tiptxt link_blue">
                我们强烈建议您认证企业营业执照，因为求职者更信任认证过的企业。
            </div>
        </div>
        <if condition="($Think.get.anew eq 1 AND $company_profile['audit'] neq '1') OR $company_profile['audit'] eq '0'">
            <!--提交表单-->
            <div class="plan default">
                <span class="s1">1 提交营业执照</span>
                <span class="s2">2 等待审核</span>
                <span class="s3">3 审核结果</span>
                <div class="clear"></div>
            </div>
            <div class="authentication">
                <form id="authentication_form" action="{:U('company/com_auth')}" method="post">
                    <div class="mb16 J_validate_group">
                        <div class="key">企业名称：</div>
                        <div class="val">{$company_profile.companyname}</div>
                        <div class="clear"></div>
                    </div>
                    <div class="mb16 J_validate_group">
                        <div class="key">上传营业执照：</div>
                        <div id="J_imgWrap" class="val">
                            <div class="J_tipWrap tipWrap">
                                <div class="upload_tip link_blue">
                                    注册号、企业名称、法人代表、年检章等需清晰可辨。
                                    <a class="tips_right" href="javascript:;">[查看示例]
                                        <div class="des_box">
                                            <div class="des_arrow"></div>
                                            <div class="des_txt"></div>
                                        </div>
                                    </a>
                                </div>
                                <div class="upload_type">
                                    <div class="new-up-cell">
                                        <div class="img-box">
                                            <img src="{:C('qscms_site_dir')}index.php?m=Home&c=Qrcode&a=index&url={:urlencode(build_mobile_url(array('c'=>'ScanUpload','a'=>'certificate_img','params'=>'uname='.$visitor['username'].'&pwd='.$visitor['password'])))}" />
                                        </div>
                                        <div class="sp-line-16"></div>
                                        <div class="l-txt co-333 ft-16">方式一：手机扫码上传</div>
                                        <div class="sp-line-13"></div>
                                        <div class="l-txt co-b9 ft-14">推荐使用手机扫码上传图片，更方便</div>
                                    </div>
                                    <div class="new-up-cell last">
                                        <div class="img-box local-up J_hoverbut" id="certificate_img" name="certificate_img">
                                            <div class="i-ic"></div>
                                            <div class="sp-line-19"></div>
                                            <div class="l-txt ft-16">点击上传</div>
                                        </div>
                                        <div class="sp-line-16"></div>
                                        <div class="l-txt co-333 ft-16">方式二：本地上传</div>
                                        <div class="sp-line-13"></div>
                                        <div class="l-txt co-b9 ft-14">jpg/gif/png格式（大小2MB以内）</div>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" id="certificate_img_up" name="certificate_img_up" value="">
                        <input type="hidden" name="anew" value="{$Think.get.anew|default=0}">
                        <div class="tip_box pl0 J_showtip_box"></div>
                        <div class="clear"></div>
                    </div>
                </form>
            </div>
            <else/>
            <switch name="company_profile['audit']">
                <case value="1">
                    <!--审核通过-->
                    <div class="plan not">
                        <span class="s1">1 提交营业执照</span>
                        <span class="s2">2 等待审核</span>
                        <span class="s3">3 审核结果</span>
                        <div class="clear"></div>
                    </div>
                    <div class="authentication pass">
                        <div class="planIco">审核通过</div>
                        <div class="planTip">恭喜您，您提交的营业执照通过审核了！</div>
                    </div>
                </case>
                <case value="2">
                    <!--等待审核-->
                    <div class="plan wait">
                        <span class="s1">1 提交营业执照</span>
                        <span class="s2">2 等待审核</span>
                        <span class="s3">3 审核结果</span>
                        <div class="clear"></div>
                    </div>
                    <div class="authentication wait">
                        <div class="planIco">认证资料已提交，等待审核中</div>
                        <div class="imgs">
                            <img src="{:attach($company_profile['certificate_img'],'certificate_img')}">
                        </div>
                        <div class="planTip link_blue">我们会在1个工作日内审核您的资料，如需修改请 <a href="{:U('company/com_auth',array('anew'=>1))}">[重新上传]</a></div>
                    </div>
                </case>
                <case value="3">
                    <!--审核不通过-->
                    <div class="plan not">
                        <span class="s1">1 提交营业执照</span>
                        <span class="s2">2 等待审核</span>
                        <span class="s3">3 审核结果</span>
                        <div class="clear"></div>
                    </div>
                    <div class="authentication not">
                        <div class="planIco">审核不通过</div>
                        <div class="planTip">
                            您好，您提交的营业执照未通过审核，请<a class="font_blue" href="{:U('company/com_auth',array('anew'=>1))}">重新认证</a><br/>
                            <span>原因：{$reason}</span>
                        </div>
                    </div>
                </case>
            </switch>
        </if>
    </div>
    <div class="clear"></div>
</div>
</body>
<include file="index_footer"/>
<script src="../public/js/ajaxfileupload.js"></script>
<script type="text/javascript" src="../public/js/jquery.validate.js"></script>
<script src="../public/js/qscms.js"></script>
<script type="text/javascript">
    // 扫码上传
    var scanimg_time, get_anew = {:I('request.anew',0,'intval')}, audit = {$company_profile['audit']}, uid = {$company_profile['uid']},
    waiting_img_scan = function(){
        $.getJSON("{:U('Company/ajax_certificate_img_waiting')}", {uid:uid}, function(result){
            if(result.status == 1){
                if($('#authentication_form').length){
                    $('input[name="certificate_img_up"]').val(result.data.img);
                    $('#authentication_form').submit();
                } else {
                    $('.imgs img').attr('src',result.data.url);
                }
            }
        });
    };
    if ((get_anew == 1 && audit != 1) || audit == 0) {
        scanimg_time = setInterval(waiting_img_scan,5000);
    }
    // 本地上传
    $.upload('#certificate_img', {type: 'certificate_img'}, function (result) {
        if (result.status == 1) {
            window.location.href="{:U('company/com_auth')}";
        } else {
            alert(result.msg);
        }
    });
    // 验证
    $("#authentication_form").validate({
        rules: {
            certificate_img_up: {
                required: true
            }
        },
        messages: {
            certificate_img_up: {
                required: '<div class="ftxt">请上传营业执照</div><div class="fimg"></div>'
            }
        },
        errorClasses: {
            certificate_img_up: {
                required: 'tip err'
            }
        },
        errorElement: 'div',
        errorPlacement: function (error, element) {
            console.log(element);
            element.closest('.J_validate_group').find('.J_showtip_box').append(error);
        },
        success: function (label) {
            label.append('<div class="ok"></div>');
        }
    });

</script>
</html>